{extend name="layout/popup" /}
{block name="content"}
<link rel="stylesheet" href="__ADMIN__/css/formSelects-v4.css"/>
<input type="hidden" name="ajax" id="ajax" value="1">
<div class="popup-header">
    <h1>添加候选人</h1>
</div>
<div class="popup-body">
    <div class="space-20"></div>
    <form id="form_data" class="layui-form" method="post" action="{:url('save')}">
        <input type="hidden" name="opmode" value="add">
        <input type="hidden" name="aid" value="{$aid}">
        <div class="layui-row">

            <div class="layui-col-xs11">
                <div class="layui-form-item">
                    <label class="layui-form-label required">候选人：</label>
                    <div class="layui-input-block w19">
                        <select name="sid">
                            {:fill_option($staff_list, 'id', 'nickname')}
                        </select>
                    </div>
                </div>
            </div>

            <div class="layui-col-xs11">
                <div class="layui-form-item">
                    <label class="layui-form-label required">员工形象照：</label>
                    <div class="layui-input-block w19">
                        <div class="image-upload wp100">
                            <div class="input">
                                <input type="hidden" class="image-url" name="profile_pic" info="员工形象照" value="" />
                            </div>
                            <div class="image-upload-btn">
                                <p>上传形象照: 200*200</p>
                            </div>
                            <div class="image"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-col-xs11">
                <div class="layui-form-item">
                    <label class="layui-form-label required">推荐简介：</label>
                    <div class="layui-input-block w19">
                        <input type="text" name="desc" placeholder="" class="layui-input" info="推荐简介" value="" />
                    </div>
                </div>
            </div>

            <div class="layui-col-xs11">
                <div class="layui-form-item">
                    <label class="layui-form-label required">推荐词：</label>
                    <div class="layui-input-block w19">
                        <textarea class="layui-textarea layui-hide" name="recommendation" info="推荐词" id="layui-editor"></textarea>
                    </div>
                </div>
            </div>

        </div>
        <div class="space-20"></div>
    </form>
</div>
<div class="popup-footer">
    <a class="layui-btn layui-btn-primary" onclick="popup_close();">取消</a>
    <a class="layui-btn" lay-submit="" lay-filter="demo2" onclick="save();">确定</a>
</div>
{/block}

{block name="script"}
<script>
    layui.use(['form', 'jquery', 'layedit', 'uploader'], function () {
        let $ = layui.jquery,
        layedit = layui.layedit;

        var editIndex = layedit.build('layui-editor');
        var fn = {
            select_dept: function () {
                winopen("{:url('select_dept')}", 560, 470);
            },
            save: function () {
                // 同步富文本内容
                layedit.sync(editIndex);
                
                send_form("form_data", "{:url('save')}", function (res) {
                    if (res.code) {
                        layer.msg(res.msg, {
                            time: 1200
                        }, function () {
                            popup_close();
                            parent.location.reload(true);
                        });
                    } else {
                        layer.msg(res.msg);
                        return false;
                    }
                });
            }
        };
        win_exp(fn);

    });
</script>
{/block}
